package ClassWork.Work_02;

import java.util.Scanner;

public class Calculator {
    public static void main(String[] args) {
        double x=0;
        Scanner sc = new Scanner(System.in);
        while(true){
            System.out.println("请输入第一个数字");
            double num1 = sc.nextDouble();
            System.out.println("请输入第二个数字");
            double num2 = sc.nextDouble();
            System.out.println("请输入要做的计算" + "\n" + "加：+，减：-，乘：*，除：/，取余：%");
            String num3 = sc.next();
            if("+".equals(num3)){
                x=num1+num2;
            }else if("-".equals(num3)){
                x=num1-num2;
            }else if("*".equals(num3)){
                x=num1*num2;
            }else if("/".equals(num3)){
                if(num2!=0){
                    x=num1/num2;
                }else{
                    System.out.println("除数不能为零！");
                    break;
                }
            }else if("%".equals(num3)){
                x=num1%num2;
            }else{
                System.out.println("输入有误");
                break;
            }
            System.out.println("结果为：" + x);
            x=0;
        }

    }
}
